package com.ccp.dev.workflow.service;

import org.flowable.bpmn.model.FlowableListener;
import org.springframework.stereotype.Service;

/**
 * ClassDescribe:
 * 监听器服务类
 * @author :wangcheng
 * Date: 2019-05-13
 */
@Service
public class ListenerService {
    public static final String TASK_CREATE_LISTENER = "${taskCreateListener}";
    public static final String TASK_SIGN_CREATE_LISTENER = "${taskSignCreateListener}";
    public static final String TASK_DELETE_LISTENER = "${taskDeleteListener}";
    public static final String EXECUTION_START_LISTENER = "${startEventListener}";
    public static final String EXECUTION_END_LISTENER = "${endEventListener}";
    public static final String AUTO_TASK_LISTENER = "${autoTaskListener}";
    public static final String SUB_PROCESS_START_LISTENER = "${subProcessStartListener}";
    public static final String SUB_PROCESS_END_LISTENER = "${subProcessEndListener}";
    public static final String CALL_SUB_PROCESS_START_LISTENER = "${callSubProcessStartListener}";
    public static final String CALL_SUB_PROCESS_END_LISTENER = "${callSubProcessEndListener}";


    /**
     * 生成监听器
     * @param event 监听事件
     * @param implType 实现类型
     * @param implementation 代理类
     * @return 监听器
     */
    public FlowableListener generateListener(String event, String implType, String implementation) {
        FlowableListener flowableListener = new FlowableListener();
        flowableListener.setImplementationType(implType);
        flowableListener.setEvent(event);
        flowableListener.setImplementation(implementation);
        return flowableListener;

    }
}
